﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Osiptel.HECO.BE;
using System.Data.OracleClient;
using System.Data;

namespace Osiptel.HECO.DL
{
    public class Predefinido4DL
    {
        
        public int mInsertar(Predefinido4BE Predefinido4)
        {
            
            try
            {
                Int32 id = 0;

                using (OracleCommand cmd = new OracleCommand())
                {
                    cmd.CommandText = "PKG_HECO_GLOBAL.SP_INSERTAR_PREDEFINIDO4";
                    cmd.CommandType = CommandType.StoredProcedure;

                    OracleParameter prm1 = new OracleParameter("PSALTOS", OracleType.Number);
                    OracleParameter prm2 = new OracleParameter("PCAPACIDADMBPS", OracleType.Number);
                    OracleParameter prm3 = new OracleParameter("PUSUCRE", OracleType.VarChar);
                    OracleParameter prm4 = new OracleParameter("PIPREG", OracleType.VarChar);
                    OracleParameter prm5 = new OracleParameter("PIDPREDEF4", OracleType.Number);

                    prm1.Direction = ParameterDirection.Input;
                    prm2.Direction = ParameterDirection.Input;
                    prm3.Direction = ParameterDirection.Input;
                    prm4.Direction = ParameterDirection.Input;
                    prm5.Direction = ParameterDirection.Output;

                    prm1.Value = Predefinido4.Saltos;
                    prm2.Value = Predefinido4.CapacidadMbps;                
                    prm3.Value = Predefinido4.UsuCre;
                    prm4.Value = Predefinido4.IpReg;
                    prm5.Value = Predefinido4.IdPredefinido;

                    cmd.Parameters.Add(prm1);
                    cmd.Parameters.Add(prm2);
                    cmd.Parameters.Add(prm3);
                    cmd.Parameters.Add(prm4);
                    cmd.Parameters.Add(prm5);

                    using (DL_CONEXION NewConexion = new DL_CONEXION())
                    {
                        int ret = NewConexion.ejecutaSQL(cmd);
                        id = Convert.ToInt32(Convert.ToString(cmd.Parameters["PIDPREDEF4"].Value));
                        return id;
                    }                    
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }       
    }
}
